home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / nortutil.zip / src / TaxLaw / wrap.c < prev   
C/C++ Source or Header  |  1996-08-28  |  946b  |  49 lines

  1. #include <stdio.h>
  2. /*
  3. main()
  4. {
  5. char buffer[200];
  6.  
  7.         gets(buffer);
  8.         wrap_puts(buffer);
  9. }
  10. */
  11. #define endcol 75 
  12.  
  13. wrap_puts(string)
  14. char *string;
  15. {
  16. char *ps,*psp;
  17. int counter; 
  18.  
  19.         ps = psp = string;
  20.         counter = 0;
  21.         for(;;)
  22.         {
  23.                 while( (*psp != ' ') && (*psp != '\0') )
  24.                 {
  25.                         psp++;
  26.                         counter++;
  27.                 }
  28.                 counter++;
  29.  
  30.                 if(counter > endcol)
  31.                 {
  32.                         putchar('\n');
  33.                         ps++;
  34.                         counter = 0;
  35.                 }
  36.                 else
  37.                         counter++;
  38.  
  39.                 while(ps != psp)
  40.                         putchar(*ps++);
  41.                 
  42.                 if(*psp == '\0')
  43.                         break;
  44.  
  45.                 psp++;
  46.         }
  47.         putchar('\n');
  48. }
  49.